package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.JOptionPane;

public class CheckAmountRentBook {
	int amountBook;
	public CheckAmountRentBook(String idMem) {
		try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/library_community","root","1234");
			PreparedStatement statement = con.prepareStatement("select MEMBER_RENT_AMOUNT_BOOK  from lcmm_member where '" +
					idMem + "' = MEMBER_ID");
			ResultSet result = statement.executeQuery();
			result.next();
			amountBook = result.getInt(1);
			result.close();
			statement.close();
			con.close();
		}catch (Exception e) {
			JOptionPane.showMessageDialog(null,e);
		}
	}

	public int GetAmountBook() {
		return amountBook;
	}
}
